﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;

namespace Gladkikh.Sims2.Combiner
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {

            recoverAppConfig();
        	    
            

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            
			sc = new SplashScreen();
			sc.Show();
			Application.DoEvents();
            Application.Run(new Form1());
        }
        
        static public SplashScreen sc;

        private static void recoverAppConfig()
        {
        	try
        	{
            if (!File.Exists(Path.GetFileName(Application.ExecutablePath) + ".config"))
            {
                FileStream fs = new FileStream(Path.GetFileName(Application.ExecutablePath) + ".config", FileMode.Create);
                BinaryWriter br = new BinaryWriter(fs);

                br.Write(Gladkikh.Sims2.Combiner.Properties.Resources.app, 0,
                        Gladkikh.Sims2.Combiner.Properties.Resources.app.Length);

                br.Close();
                fs.Close();
            }
        	}
        	catch(IOException e)
        	{
        		MessageBox.Show(e.Message, "Some IO error happend");
        		Application.Exit();
        	}
        }
    }
}
